game_manager
	{
	spawn
		{
		wm_axis_respawntime 15
		wm_allied_respawntime 15
		wm_set_round_timelimit	25

		wm_setwinner 0

		wm_number_of_objectives	8
		wm_objective_status 		1 0 0	//Tank
		wm_objective_status 		1 1 0
		wm_objective_status 		2 0 0	//Left Wall
		wm_objective_status 		2 1 0
		wm_objective_status 		3 0 0	//Tunnel Wall
		wm_objective_status 		3 1 0
		wm_objective_status 		4 0 0	//Flag
		wm_objective_status 		4 1 0
		wm_objective_status 		5 0 0	//Safe Door
		wm_objective_status 		5 1 0
		wm_objective_status 		6 0 0	//Secret Docs
		wm_objective_status 		6 1 0
		wm_objective_status 		7 0 0	//CP
		wm_objective_status 		7 1 0
		wm_objective_status 		8 0 0	//Fence
		wm_objective_status 		8 1 0

		wm_set_defending_team	0

		wait 100
		setautospawn "Beach Spawn"			1
		setautospawn "Bunker Spawn"			0

		
		wm_addteamvoiceannounce 1 "allies_hq_tank_escort"
		wm_addteamvoiceannounce 0 "axis_hq_tank_stop"

		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		

		setstate tank invisible
		setstate bunker_big_door invisible
		setstate bunker_small invisible
		trigger bunker_small_door open_and_lock_bunker_small_door

		mu_stop 0
		}
	trigger end_game
		{
		wm_setwinner 1
		wait 2500
		wm_endround
		}
	}
	
bunker_big_door
{
	spawn
	{
		remove
	}
}

bunker_small_door_tst
{
	spawn
	{
		remove
	}
}

bunker_spawn_flag
{
	spawn
	{
		accum 0 set 0	// Who has the flag: 0-Axis, 1-Allied
		remove
	}
	trigger axis_capture	// Flag has been touched by an Axis player
	{
		accum 0 abort_if_equal 0 // do Axis own flag?
		accum 0 set 0 // Axis own the pole

		wm_announce	"Axis reclaimed Bunker!"
		alertentity bunker_spawn_wobj

		setautospawn "Beach Spawn"			1
		setautospawn "Bunker Spawn"			0

		wm_objective_status 		4 0 1
		wm_objective_status 		4 1 2
	}
	trigger allied_capture	// Flag has been touched by an allied player
	{
		accum 0 abort_if_equal 1 // do Allies own flag?
		accum 0 set 1 // Allied own the flag

		wm_announce	"Allies captured Bunker!"
		alertentity bunker_spawn_wobj

		setautospawn "Bunker Spawn"			1
		setautospawn "Radar Spawn"			0

		wm_objective_status 		4 0 2
		wm_objective_status 		4 1 1
	}
}

main_gate
{
	spawn
	{
		remove
	}
	trigger destroyed
	{
		trigger tank_shell_hurt_1 hurt
		trigger tank_shell_hurt_2 hurt
		trigger tank_shell_hurt_3 hurt
		wait 150
		alertentity main_gate
		wm_announce "Main Gate has been destroyed!"
		
		wm_removeteamvoiceannounce 1 "allies_hq_tank_escort"
		wm_removeteamvoiceannounce 0 "axis_hq_tank_stop"

		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"
	}
}
tank_shell_hurt_1
{
	spawn
	{
		wait 100
		setstate tank_shell_hurt_1 invisible
	}
	trigger hurt
	{
		setstate tank_shell_hurt_1 default
		wait 100
		remove
	}
}
tank_shell_hurt_2
{
	spawn
	{
		wait 100
		setstate tank_shell_hurt_2 invisible
	}
	trigger hurt
	{
		wait 100
		setstate tank_shell_hurt_2 default
		wait 100
		remove
	}
}
tank_shell_hurt_3
{
	spawn
	{
		wait 100
		setstate tank_shell_hurt_3 invisible
	}
	trigger hurt
	{
		wait 200
		setstate tank_shell_hurt_3 default
		wait 100
		remove
	}
}

LeftWall
{
	spawn
	{
	set
		{
		wait 100
		constructible_class 1
		health "20"
		}
	}
	death
	{
		wm_announce "Left Wall has been destroyed!"
		wm_objective_status 		2 0 2
		wm_objective_status 		2 1 1

		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"
	}
}
RightWall
{
	spawn
	{
	set
		{
		wait 100
		constructible_class 1
		health "20"
		}
	}
	death
	{
		wm_announce "Tunnel Wall has been destroyed!"
		wm_objective_status 		3 0 2
		wm_objective_status 		3 1 1

		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"
	}
}
SafeDoor
{
	spawn
	{
	set
		{
		wait 100
		constructible_class 1
		health "20"
		}
	}
	death
	{
		alertentity electric_wires
		trigger bunker_small_door open_and_lock_bunker_small_door
		alertentity bunker_big_door
		alertentity bunker_window_clip

		wm_announce "Safe Door has been destroyed!"
		wm_objective_status 		5 0 2
		wm_objective_status 		5 1 1

		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"
	}
}
Fence
{
	spawn
	{
		setstate fence invisible
		setstate fence_materials_clip invisible
		setstate fence_materials_model invisible
		setstate fence_materials_flag invisible
		remove
	}
	buildstart final
	{
		setstate fence underconstruction
		setstate fence_materials_clip default
		setstate fence_materials_model default
		setstate fence_materials_flag default
	}
	decayed final
	{
		setstate fence invisible
		setstate fence_materials_clip default
		setstate fence_materials_model default
		setstate fence_materials_flag default
	}
	built final
	{
		wm_announce "Fence has been built!"
		wm_objective_status 		8 0 2
		wm_objective_status 		8 1 1

		wm_teamvoiceannounce 1 "allies_hq_const_completed"
		wm_teamvoiceannounce 0 "axis_hq_const_completed"

		setstate fence default
		setstate fence_materials_clip invisible
		setstate fence_materials_model invisible
		setstate fence_materials_flag invisible
	}
	death
	{
		wm_announce "Fence has been destroyed!"
		wm_objective_status 		8 0 2
		wm_objective_status 		8 1 1

		wm_teamvoiceannounce 1 "allies_hq_objective_destroyed"
		wm_teamvoiceannounce 0 "axis_hq_objective_destroyed"

		setstate fence invisible
		setstate fence_materials_clip default
		setstate fence_materials_model default
		setstate fence_materials_flag default
	}
}
SecretDocsCappoint
{
	death
	{
		wm_announce "Secret Documents transmitted!"
		wm_objective_status 		6 0 2
		wm_objective_status 		6 1 1

		wm_teamvoiceannounce 1 "allies_hq_objective_captured"
		wm_teamvoiceannounce 0 "axis_hq_objective_lost"
		trigger game_manager end_game
	}
}

bunker_small_door
{
	spawn
	{
		wait 100
		set
			{
			key "0"
			}
		accum 2 set 1
		alertentity lock_bunker_small_door
		wait 10
		accum 1 abort_if_greater_than 0
		trigger self open_bunker_small_real
		trigger self open_bunker_small_fake
	}
	trigger door_sent_signal
	{
		accum 1 inc 1
		accum 1 trigger_if_equal 1 bunker_small_door open_doors
	}

	trigger open_doors
	{
		alertentity lock_bunker_small_door
		trigger self open_bunker_small_real
		wait 3000
		accum 2 abort_if_equal 1
		trigger self close_bunker_small_real
		trigger self close_bunker_small_fake
	}
	trigger open_bunker_small_real
	{
		alertentity bunker_small_door_left
		alertentity bunker_small_door_right
	}
	trigger open_bunker_small_fake
	{
		alertentity bunker_small_door
	}
	trigger close_bunker_small_real
	{
		accum 2 abort_if_equal 1
		alertentity bunker_small_door_left
		alertentity bunker_small_door_right
	}
	trigger close_bunker_small_fake
	{
		wait 800
		accum 2 abort_if_equal 1
		alertentity bunker_small_door
		wait 400
		accum 1 set 0
		alertentity unlock_bunker_small_door
	}
	trigger open_and_lock_bunker_small_door
	{
		accum 2 set 1
		alertentity lock_bunker_small_door
		wait 1500
		accum 1 abort_if_greater_than 0
		trigger self open_bunker_small_real
		trigger self open_bunker_small_fake
		
	}
}
circuit_radartop
{
	spawn
	{
		wait 100
		trigger circuit_radartop up
	}
	trigger up
	{
		stopsound
		playsound sound/vehicles/misc/radar_start.wav volume 64

		startanimation 0 35 15 nolerp norandom noloop
		wait 2500
		startanimation 34 1 15 norandom noloop
		setrotation 0 30 0
	}
}

// ================================================
// ============ NEUTRAL COMMAND POST ==============
// ================================================
allied_compost_built
{
	spawn
	{
		wait 400
		trigger allied_compost_built setup
		constructible_class 2
	}
	trigger setup
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0
	}
	buildstart final
	{
		setstate allied_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}
	built final
	{
		setstate allied_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger allied_compost_built_model enable_allied_features
		enablespeaker allies_compost_sound
	}
	decayed final
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}
	death
	{
		setstate allied_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger allied_compost_built_model disable_allied_features
		disablespeaker allies_compost_sound
	}
}
allied_compost_built_model
{
	spawn
	{
		wait 400
		setstate allied_compost_built_model invisible
	}
	trigger enable_allied_features
	{
		setchargetimefactor 1 soldier 0.75
		setchargetimefactor 1 lieutenant 0.75
		setchargetimefactor 1 medic 0.75
		setchargetimefactor 1 engineer 0.75
		setchargetimefactor 1 covertops 0.75
		sethqstatus 1 1

		wm_announce	"Allied Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed_allies"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed"

		wm_removeteamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 7 0 2
		wm_objective_status 7 1 1
	}
	trigger disable_allied_features
	{
		setchargetimefactor 1 soldier 1
		setchargetimefactor 1 lieutenant 1
		setchargetimefactor 1 medic 1
		setchargetimefactor 1 engineer 1
		setchargetimefactor 1 covertops 1
		sethqstatus 1 0

		wm_announce	"Axis team has destroyed the Allied Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_construct"
		wm_teamvoiceannounce 1 "allies_hq_compost_damaged"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 7 0 0
		wm_objective_status 7 1 0
	}
}
axis_compost_built
{
	spawn
	{
		wait 400
		trigger axis_compost_built setup
		constructible_class 2
	}
	trigger setup
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0
	}
	buildstart final
	{
		setstate axis_compost_built_model underconstruction
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible
	}
	built final
	{
		setstate axis_compost_built_model default
		setstate neutral_compost_closed_clip invisible
		setstate neutral_compost_closed_model invisible

		trigger axis_compost_built_model enable_axis_features
		enablespeaker axis_compost_sound
	}
	decayed final
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default
	}
	death
	{
		setstate axis_compost_built_model invisible
		setstate neutral_compost_closed_clip default
		setstate neutral_compost_closed_model default

		trigger axis_compost_built_model disable_axis_features
		disablespeaker axis_compost_sound
	}
}
axis_compost_built_model
{
	spawn
	{
		wait 400
		setstate axis_compost_built_model invisible
	}
	trigger enable_axis_features
	{
		setchargetimefactor 0 soldier 0.75
		setchargetimefactor 0 lieutenant 0.75
		setchargetimefactor 0 medic 0.75
		setchargetimefactor 0 engineer 0.75
		setchargetimefactor 0 covertops 0.75
		sethqstatus 0 1

		wm_announce	"Axis Command Post constructed. Charge speed increased!"

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_compost_constructed"
		wm_teamvoiceannounce 1 "allies_hq_compost_constructed_axis"

		wm_removeteamvoiceannounce 0 "axis_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 7 0 1
		wm_objective_status 7 1 2
	}
	trigger disable_axis_features
	{
		setchargetimefactor 0 soldier 1
		setchargetimefactor 0 lieutenant 1
		setchargetimefactor 0 medic 1
		setchargetimefactor 0 engineer 1
		setchargetimefactor 0 covertops 1
		sethqstatus 0 0

		wm_announce	"Allied team has destroyed the Axis Command Post!"

		// *----------------------------------- vo ------------------------------------------*
		wm_addteamvoiceannounce 0 "axis_hq_compost_construct"
		wm_addteamvoiceannounce 1 "allies_hq_compost_construct"

		wm_teamvoiceannounce 0 "axis_hq_compost_damaged"
		wm_teamvoiceannounce 1 "allies_hq_compost_construct"
		// *---------------------------------------------------------------------------------*

		wm_objective_status 7 0 0
		wm_objective_status 7 1 0
	}
}
//============================================================================
//============================================================================
tank_sound
{
	trigger start
	{
		trigger tank sound_start
		wait 3400
		trigger tank sound_move
	}
	trigger stop
	{
		trigger tank sound_stop
		wait 1400
		trigger tank sound_idle
	}
	trigger rebirth
	{
		trigger tank sound_rebirth
		wait 1400
		trigger tank sound_idle
	}
}
tank
{
	spawn
	{
		wait 50
		trigger self sound_idle

		accum 1 bitset 5
		trigger self tracks_stop

		followspline 0 spln0 10000 wait length -64
		followspline 1 spln0 10000 wait length -64
	}


	trigger startfire
	{
		startanimation 67 8 10 nolerp norandom
	}

	trigger stopfire
	{
		startanimation 0 1 15 nolerp norandom
	}


	trigger sound_idle
	{
		stopsound
		playsound sound/vehicles/tank/tank_idle.wav looping volume 512
	}
	trigger sound_start
	{
		stopsound
		playsound sound/vehicles/tank/tank_revup.wav volume 196
	}
	trigger sound_move
	{
		stopsound
		playsound sound/vehicles/tank/tank_move.wav looping volume 512
	}
	trigger sound_stop
	{
		stopsound
		playsound sound/vehicles/tank/tank_revdown.wav volume 196
	}
	trigger sound_death
	{
		stopsound
		playsound sound/vehicles/tank/tank_stop.wav volume 256
	}
	trigger sound_rebirth
	{
		stopsound
		playsound sound/vehicles/tank/tank_start.wav volume 196
	}


	trigger tracks_forward
	{
		accum 1 abort_if_bitset 5
		accum 1 bitset 5

		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	trigger tracks_turningleft
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_forward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_backward
		remapshaderflush
	}
	trigger tracks_turningright
	{
		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_backward
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_backward
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_forward
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_forward
		remapshaderflush
	}
	trigger tracks_stop
	{
		accum 1 abort_if_not_bitset 5
		accum 1 bitreset 5

		remapshader models/mapobjects/tanks_sd/bits_r models/mapobjects/tanks_sd/bits_r
		remapshader models/mapobjects/tanks_sd/wheel_r models/mapobjects/tanks_sd/wheel_r
		remapshader models/mapobjects/tanks_sd/bits_l models/mapobjects/tanks_sd/bits_l
		remapshader models/mapobjects/tanks_sd/wheel_l models/mapobjects/tanks_sd/wheel_l
		remapshaderflush
	}
// ===========================================================================================
	trigger run_incpos
	{
		accum 3 inc 1
	}
	trigger run_continue
	{
		trigger self run_incpos
		trigger self deathcheck
		trigger self stopcheck
		trigger self move
	}
// ===========================================================================================
	trigger move_check
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3

		trigger self dispatch
	}
	trigger move
	{
		trigger self move_check

		wait 500

		trigger self move
	}
	trigger dispatch
	{
		accum 3 trigger_if_equal 0 tank run_0
		accum 3 trigger_if_equal 1 tank run_1
		accum 3 trigger_if_equal 2 tank run_2
		accum 3 trigger_if_equal 3 tank run_3
		accum 3 trigger_if_equal 4 tank run_4
		accum 3 trigger_if_equal 5 tank run_5
		accum 3 trigger_if_equal 6 tank run_6
		accum 3 trigger_if_equal 7 tank run_7
		accum 3 trigger_if_equal 8 tank run_8
		accum 3 trigger_if_equal 9 tank run_9
		accum 3 trigger_if_equal 10 tank run_10
		accum 3 trigger_if_equal 11 tank run_11
		accum 3 trigger_if_equal 12 tank run_12
		accum 3 trigger_if_equal 13 tank run_13
	}
// ===========================================================================================
	trigger run_0
	{
		accum 1 bitset 2
		trigger tank_turret2 run_0
		followspline 0 spln0 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_1
	{
		accum 1 bitset 2
		trigger tank_turret2 run_1
		followspline 0 spln1 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_2
	{
		accum 1 bitset 2
		trigger tank_turret2 run_2
		followspline 0 spln2 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_3
	{
		accum 1 bitset 2
		trigger tank_turret2 run_3
		followspline 0 spln3 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_4
	{
		accum 1 bitset 2
		trigger tank_turret2 run_4
		followspline 0 spln4 80 wait length -64
		accum 1 bitreset 2

		trigger self run_continue
	}
	trigger run_5
	{
		accum 1 bitset 2
		trigger tank_turret2 run_5

	//	trigger self 		tracks_turningleft

		followspline 0 spln5 80 wait length -64

	//	accum 1 bitreset 5
	//	trigger self 		tracks_forward

		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_6
	{
		accum 1 bitset 2
		trigger tank_turret2 run_6
		followspline 0 spln6 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_7
	{
		accum 1 bitset 2
		trigger tank_turret2 run_7
		followspline 0 spln7 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_8
	{
		accum 1 bitset 2
		trigger tank_turret2 run_8
		followspline 0 spln8 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_9
	{
		accum 1 bitset 2
		trigger tank_turret2 run_9
		followspline 0 spln9 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_10
	{
		accum 1 bitset 2
		trigger tank_turret2 run_10
		followspline 0 spln10 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_11
	{
		accum 1 bitset 2
		trigger tank_turret2 run_11
		followspline 0 spln11 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_12
	{
		accum 1 bitset 2
		trigger tank_turret2 run_12
		followspline 0 spln12 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_13
	{
		accum 1 bitset 2
		trigger tank_turret2 run_13
		followspline 0 spln13 80 wait length -64
		accum 1 bitreset 2

		trigger self		script_lockout

		trigger self 		tracks_stop
		trigger tank_sound 	stop

		startanimation 45 	10 	15 nolerp norandom
		wait 666
		startanimation 0 	1 	15 nolerp norandom
		wait 900

		trigger self run_incpos

		trigger tank_turret turn // will break the lockout
	}
	trigger run_14
	{
		accum 1 bitset 2
		trigger tank_turret2 run_14
		followspline 0 spln14 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
	trigger run_15
	{
		accum 1 bitset 2
		trigger tank_turret2 run_15
		followspline 0 spln15 80 wait length -64
		accum 1 bitreset 2
		trigger self run_continue
	}
// ===========================================================================================
	trigger stuck_check
	{
		accum 1 bitreset 3

		trigger self stuck_check_scriptlockout
		trigger self stuck_check_finished
	}
	trigger stuck_check_finished
	{
		accum 3 abort_if_less_than 14
		accum 1 bitset 3
	}
	trigger stuck_check_scriptlockout
	{
		accum 5 abort_if_equal 0
		accum 1 bitset 3
	}
// ===========================================================================================
	trigger stopcheck_setup
	{
		accum 1 bitset 6			// stop if we're stuck/no-one's pushing :)
		accum 1 abort_if_bitset 8		// no one in the trigger, abort
		trigger self stuck_check		// call the stop check function
		accum 1 abort_if_bitset 3		// we're stuck so break out
		accum 1 bitreset 6			// we're free to move
	}
	trigger stopcheck
	{
		trigger self stopcheck_setup
		accum 1 abort_if_not_bitset 6

		trigger self script_lockout

		// Any just stopped moving stuff goes here
		trigger tank_sound 	stop
		trigger self 		tracks_stop
		startanimation 45 	10 	15 nolerp norandom
		wait 666
		startanimation 0 	1 	15 nolerp norandom
		wait 900

		trigger self script_lockout_stop
		resetscript
	}
// ===========================================================================================
	trigger script_lockout
	{
		accum 5 inc 1
	}
	trigger script_lockout_stop
	{
		accum 5 inc -1
	}
// ===========================================================================================
	trigger tank_enable
	{
		trigger self stuck_check
		accum 1 abort_if_bitset 3 	// stuck check

		accum 4 set 0				// reset stop counter
		accum 1 bitreset 8			// reset stop check

		accum 1 abort_if_bitset 2 	// already following spline
		accum 5 abort_if_not_equal 0	// are we not in a script lockout?

		accum 1 abort_if_bitset 7 	// death check

		// Any just started moving stuff goes here

		trigger self script_lockout

		trigger tank_sound start

		startanimation 55 10 15 nolerp norandom
		wait 666
		startanimation 5 40 15 nolerp norandom
		wait 500
		trigger self tracks_forward

		trigger self script_lockout_stop
		trigger self move
	}
	trigger tank_disable
	{
		accum 4 inc 1				// up the stop counter
		accum 4 abort_if_less_than 4
		accum 1 bitset 8			// set stop check
		trigger self deathcheck
	}
// ===========================================================================================
	rebirth
	{
		accum 1 bitreset 9 // we're visibly alive
		accum 1 bitreset 7 // we're alive again

		trigger self script_lockout

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_tank_repaired_allies"

		wm_teamvoiceannounce 1 "allies_hq_tank_repaired"
		// *---------------------------------------------------------------------------------*
		wm_announce "The Tank has been repaired!"

		changemodel models/mapobjects/tanks_sd/churchhill.md3

		setstate tank_smoke invisible

		trigger tank_sound rebirth
		wait 500

		trigger self script_lockout_stop
	}
	death
	{
		accum 1 bitset 7
	}

	trigger deathcheck
	{
		accum 1 abort_if_not_bitset 7	// are we dead?
		accum 1 abort_if_bitset 9		// are we not already visibly dead?
		accum 1 abort_if_bitset 2		// are we not following a spline?
		accum 5 abort_if_not_equal 0	// are we not in a script lockout?

		accum 1 bitset 9				// we're now visibly dead

		// *----------------------------------- vo ------------------------------------------*
		wm_teamvoiceannounce 0 "axis_hq_tank_damaged"

		wm_teamvoiceannounce 1 "allies_hq_tank_damaged_axis"
		// *---------------------------------------------------------------------------------*

		wm_announce "The Tank has been damaged!"

		changemodel models/mapobjects/tanks_sd/churchhill_broken.md3

		setstate tank_smoke default

		kill tank_construct

		trigger self sound_death
		trigger self tracks_stop

		trigger self script_lockout

		trigger self tracks_stop
		startanimation 45 10 15 nolerp norandom
		wait 666
		startanimation 0 1 15 nolerp norandom

		trigger self script_lockout_stop

		resetscript
	}
}

tank_disabler
{
	trigger run
	{
		trigger tank tank_disable
	}
}
tank_enabler
{
	trigger run
	{
		trigger tank tank_enable
	}
}
tank_trigger
{
	spawn
	{
		wait 100
		attachtotag tank tag_turret
	}
}
tank_build
{
	spawn
	{
		wait 100
		attachtotag tank tag_turret
	}
}
tank_construct
{
	spawn
	{
		wait 400
		constructible_class 2
		constructible_health 1200
	}
	built final
	{
		alertentity tank
	}
	trigger final_pos
	{
		constructible_constructxpbonus 3
		constructible_destructxpbonus 3
	}
}
//================================================================================
// Physical tank turret MODEL
//================================================================================
tank_turret
{
	spawn
	{
		wait 100
		attachtotag tank tag_turret
	}

	trigger turn
	{
		wait 1000

		trigger tank_turret2 spin_start
		trigger tank_turret2 turn
		faceangles 0 -11 0 2000
		trigger tank_turret2 spin_stop

		wait 500

		trigger tank startfire
		trigger tank_turret2 avre_fire
		trigger tank_flash run
	}

	trigger blow_door
	{
		setstate tank_flash invisible

		wait 200
		trigger tank stopfire

		trigger main_gate destroyed

		wait 200
		trigger tank_turret2 spin_start
		trigger tank_turret2 turn_back
		faceangles 0 0 0 2000
		trigger tank_turret2 spin_stop

		trigger tank script_lockout_stop
	}
}
//================================================================================
// Metal CLIP brush tank turret
//================================================================================
tank_turret2
{
	spawn
	{
		wait 50
		followspline 0 spln0 10000 wait length -64
		followspline 1 spln0 10000 wait length -64
	}


	trigger avre_fire
	{
		playsound sound/vehicles/tank/tank_fire.wav volume 300
	}
	trigger spin_start
	{
		stopsound
		playsound sound/vehicles/tank/turret_spin.wav looping volume 127
	}
	trigger spin_stop
	{
		stopsound
		playsound sound/vehicles/tank/turret_end.wav volume 96
	}


	trigger turn
	{
		faceangles 0 111 0 2000
	}
	trigger turn_back
	{
		faceangles 0 100 0 2000
	}


	trigger run_0
	{
		followspline 0 spln0 80 wait length -64
	}
	trigger run_1
	{
		followspline 0 spln1 80 wait length -64
	}
	trigger run_2
	{
		followspline 0 spln2 80 wait length -64
	}
	trigger run_3
	{
		followspline 0 spln3 80 wait length -64
	}
	trigger run_4
	{
		followspline 0 spln4 80 wait length -64
	}
	trigger run_5
	{
		followspline 0 spln5 80 wait length -64
	}
	trigger run_6
	{
		followspline 0 spln6 80 wait length -64
	}
	trigger run_7
	{
		followspline 0 spln7 80 wait length -64
	}
	trigger run_8
	{
		followspline 0 spln8 80 wait length -64
	}
	trigger run_9
	{
		followspline 0 spln9 80 wait length -64
	}
	trigger run_10
	{
		followspline 0 spln10 80 wait length -64
	}
	trigger run_11
	{
		followspline 0 spln11 80 wait length -64
	}
	trigger run_12
	{
		followspline 0 spln12 80 wait length -64
	}
	trigger run_13
	{
		followspline 0 spln13 80 wait length -64
	}
	trigger run_14
	{
		followspline 0 spln14 80 wait length -64
	}
	trigger run_15
	{
		followspline 0 spln15 80 wait length -64
	}
}

tank_smoke
{
	spawn
	{
		wait 300
		attachtotag tank tag_turret
		setstate tank_smoke invisible
	}
}
tank_flash
{
	spawn
	{
		setstate tank_flash invisible
	}
	trigger run
	{
		setstate tank_flash default
 		attachtotag tank_turret tag_flash
		faceangles 0 -11 0 50

		wait 50

		trigger tank_turret blow_door
	}
}

secret_room_sound
	{
	trigger play_sound
		{
		mu_start sound/nomercy/bo6.wav
		wait 2080
		mu_stop 0
		}
	}